﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Devsoft.Web.Mvc.JqGrid
{
    public class JqGridData<T>
    {
        public int page { get; set; }
        public int total { get; set; }
        public int records { get; set; }
        public IEnumerable<T> rows { get; set; }
        
        public JqGridResponse ToResponse(Func<T,object> id,params Func<T,object>[] cols)
        {
            return new JqGridResponse()
                {
                    page = page,
                    records = records,
                    total = total,
                    rows = (from r in rows select new JqGridRow(){id = id(r),cell = cols.Select(f=>f(r)).ToArray()}).ToArray()
                };
        }

    }
}
